<style rel="stylesheet/scss" lang="scss" scoped>
</style>
<template>
  <!-- 产品档案 -->
  <div class="app-container calendar-list-container pdf-containier">
    <div class="pdf-out-con">
        <el-button type="warning" :disabled="exportLoading" class="" @click="getPdf('文件导出','pdf-doc')" v-if="pageType=='export'">导出</el-button>
    </div>
    <div id="pdf-doc" :class="{'pdf-doc':pageType=='export'}">
    <!-- 基本属性 -->
    <custom-card title="基本信息" class="mt-10">
      <template>
        <basic-form v-if="!loading" :basicInfo="basicForm" :detail="pdsFileModelBaseDto" ref="basicForm" :lang="language"></basic-form>
      </template>
    </custom-card>
    <!-- 责任人 -->
    <custom-card title="责任人" class="mt-30" v-if="!loading">
      <template>
        <el-form ref="principalsForm" label-width="40%" label-suffix="：" :model="detail.pdsPlanningPrincipals">
          <el-form-item :label="item.label" :prop="item.key" v-for="(item, index) in principalLabelList" :key="'pri' + index">
            <!-- <el-select v-model="detail.pdsPlanningPrincipals[item.key]" placeholder="请选择" style="width:100%">
              <el-option v-for="(subItem, index) in principalValueList" :key="'subpri' + index" :label="subItem.name" :value="subItem.id">
              </el-option>
            </el-select> -->
            {{getValue(item.options, 'id', 'name', detail.pdsPlanningPrincipals[item.key])}}
          </el-form-item>
        </el-form>
        <div class="pds-info-tip" style="margin-top:30px">
          注：项目经理需根据此项目开发需求，确定相关外形设计、认证、测试、采购和品保等人员，并在附录1中填写。
        </div>
        <div class="pds-info-tip">
          注：项目经理根据此项目开发情况，完成附录3 中的具体个节点时间计划安排。
        </div>
      </template>
    </custom-card>
    <!-- 销售区域 -->
    <custom-card title="销售区域/国家" class="mt-30">
      <template>
        <el-form label-width="140px" class="mt-20">
          <el-form-item label="销售区域/国家">
            {{getValues('countryList', 'value', language == 'en' ? 'labelEnUs' : 'labelZhCh', detail.pdsPlanningModelSalesAreasList)}}
          </el-form-item>
          <el-form-item label="备注：">
            {{pdsFileModelBaseDto.salesAreaRemark}}
          </el-form-item>
        </el-form>
        <div class="pds-info-tip">
          注：项目经理、认证工程师需根据所选区域、国家来确定所需认证。并在附录2中填写完成。
        </div>
      </template>
    </custom-card>
    <!-- 说明书语言 -->
    <custom-card title="说明书语言要求" class="mt-30">
      <template>
        <el-form label-width="140px" class="mt-30">
          <el-form-item label="说明书语言要求：">
            {{getValues('languageList', 'value', language == 'en' ? 'labelEnUs' : 'labelZhCh', detail.pdsPlanningManual.manualLanguageDvs)}}
          </el-form-item>
          <el-form-item label="说明书格式：">
            {{detail.pdsPlanningManual.manualFormat}}
          </el-form-item>
        </el-form>
      </template>
    </custom-card>
    <!-- 市场定位 -->
    <custom-card title="市场定位" class="mt-30">
      <template>
        <el-table :data="detail.pdsConfMarketList" border fit highlight-current-row style="width: 100%">
          <el-table-column min-width="20%" align="center" label="级别" prop="marketLevelDv">
          </el-table-column>
          <el-table-column min-width="30%" align="center" label="客户群" prop="customerGroupDv">
          </el-table-column>
          <el-table-column min-width="40%" align="center" label="备注">
            <template slot-scope="scope">
              {{detail.pdsConfMarketList[scope.$index].remark}}
            </template>
          </el-table-column>
        </el-table>
      </template>
    </custom-card>
    <!-- 包装方式 -->
    <custom-card title="包装方式" class="mt-30">
      <el-form>
        <el-form ref="packingForm" label-width="140px" label-suffix="：" :model="detail.pdsPlanningPacking">
          <el-form-item label="是否有外箱">
            {{getValue(packageData.outerBoxOptions,'value',language=='en'?'labelEnUs':'labelZhCh',detail.pdsPlanningPacking.outerBox)}}
            <span v-if="detail.pdsPlanningPacking.outerBox == 1">{{detail.pdsPlanningPacking.outerBoxCapacity}}台一包</span>
          </el-form-item>
          <el-form-item label="包装类型">
            <!-- <el-radio-group v-model="detail.pdsPlanningPacking.packageType">
              <el-radio v-for="option in packageData.packageTypesOptions" :key="option.value" :label="option.value" disabled>{{language=='en'?option.labelEnUs:option.labelZhCh}}</el-radio>
            </el-radio-group> -->
            {{detail.pdsPlanningPacking.packageTypeLabel}}
          </el-form-item>
          <el-form-item label="包装标准">
            {{getValue(packageData.packageStandardOptions,'value',language=='en'?'labelEnUs':'labelZhCh',detail.pdsPlanningPacking.packageStandard)}}
          </el-form-item>
        </el-form>
      </el-form>
    </custom-card>
    <!-- 产品档案 -->
    <!-- <prod-file ref="prodfile" :standard="pdsFileModelBaseDto.standard"></prod-file> -->

    <custom-card class="mt-30" title="产品属性">
      <el-collapse v-model="activatedNames">
        <el-collapse-item :title="language=='en'?form.itemNameEn:form.itemNameCn" :name="index" v-for="(form,index) in detail.pdsModuleItemsAndValueVOList" :key="index">
          <el-col :span="8" v-for="(item,idx) in form.paramsList" :key="idx">
            <el-row class="prod-info">
              <el-col :span="10" style="text-align:right;padding-right:10px">
                {{language=='en'?item.paramNameEn:item.paramNameCn}}：
              </el-col>
              <el-col :span="14" v-if="item.paramTypeDv!='range'&&item.paramTypeDv!='radio'">
                {{item.paramValue}}{{item.paramUnitDv}}
              </el-col>
              <el-col :span="14" v-if="item.paramTypeDv=='range'">
                {{item.paramValue}}～{{item.paramMaxValue}}{{item.paramUnitDv}}
              </el-col>
              <el-col :span="14" v-if="item.paramTypeDv=='radio'">
                <span v-if="item.paramValue==1">{{language=='en'?'Y':'是'}}</span>
                <span v-if="item.paramValue==0">{{language=='en'?'N':'否'}}</span>
              </el-col>
            </el-row>
          </el-col>
        </el-collapse-item>
      </el-collapse>
    </custom-card>
    <custom-card title="产品特征" class="mt-30">
      <el-table :data="detail.pdsPlanningModelFeaturesList" border style="width: 100%">
        <el-table-column label="序号" min-width="20%" width="120px" align="center">
          <template slot-scope="scope">
            {{scope.$index+1}}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="特征" min-width="80%">
          <template slot-scope="scope">
            {{language=='en'?scope.row.nameEn:scope.row.nameCn}}
          </template>
        </el-table-column>
      </el-table>
    </custom-card>
    <custom-card title="附件" class="mt-30">
      <el-table :data="detail.pdsPlanningModelAccessories" border style="width: 100%">
        <el-table-column label="附件" min-width="50%" align="center">
          <template slot-scope="scope">
            {{language=='en'?scope.row.nameEn:scope.row.nameCn}}
          </template>
        </el-table-column>
        <el-table-column label="数量" min-width="15%" align="center">
          <template slot-scope="scope">
            {{scope.row.accessoryQuantity}}
          </template>
        </el-table-column>
      </el-table>
    </custom-card>

    <!-- 竞品对象 -->
    <custom-card title="竞品对象" class="mt-30">
      <template>
        <upload-list uploadFileId="benchmark" type="benchmark" v-model="detail.pdsBenchmarkList" :disable="true"></upload-list>
      </template>
    </custom-card>

    <!-- 使用者期望和产品关键描述 -->
    <custom-card title="使用者期望和产品关键描述" class="mt-30">
      <template>
        <el-table :data="detail.pdsPlanningExpectationList" border fit highlight-current-row style="width: 100%">
          <el-table-column min-width="20%" align="center" label="" prop="dataLabel">
          </el-table-column>
          <el-table-column min-width="40%" align="center" label="描述">
            <template slot-scope="scope">
              {{detail.pdsPlanningExpectationList[scope.$index].expectationValue}}
            </template>
          </el-table-column>
        </el-table>
      </template>
    </custom-card>
    <!-- 目标成本 -->
    <custom-card title="目标成本" class="mt-30">
      <template>
        <el-table :data="detail.pdsPlanningCostList" border fit highlight-current-row style="width: 100%">
          <el-table-column min-width="40%" align="center" label="" prop="dataLabel">
          </el-table-column>
          <el-table-column align="center" label="成本&预算">
            <template slot-scope="scope">
              {{detail.pdsPlanningCostList[scope.$index].costValue || ''}}
            </template>
          </el-table-column>
          <el-table-column align="center" label="承担方">
            <template slot-scope="scope">
              {{detail.pdsPlanningCostList[scope.$index].bearer || ''}}
            </template>
          </el-table-column>
        </el-table>
      </template>
    </custom-card>

    <!-- 知识产权归属 -->
    <custom-card title="知识产权归属" class="mt-30">
      <template>
        <el-table :data="detail.pdsPlanningIpList" border fit highlight-current-row style="width: 100%">
          <el-table-column align="center" label="" prop="dataLabel">
          </el-table-column>
          <el-table-column align="center" label="归属">
            <template slot-scope="scope">
              {{detail.pdsPlanningIpList[scope.$index].ipAscription}}
            </template>
          </el-table-column>
          <el-table-column align="center" label="保护国家">
            <template slot-scope="scope">
              {{detail.pdsPlanningIpList[scope.$index].ipProtection}}
            </template>
          </el-table-column>
        </el-table>
      </template>
    </custom-card>

    <!-- 文档附件 -->
    <custom-card title="文档附件" class="mt-30">
      <template>
        <upload-list uploadFileId="eipFile" type="eipFile" v-model="detail.eipFileList" :disable="true"></upload-list>
      </template>
    </custom-card>
</div> 
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import BasicForm from '@/components/BasicForm/showDetail';
import UploadList from '@/components/UploadList/index';
import * as baseApi from '@/api/common/index';
import * as prodApi from '@/api/product/index';
import * as planApi from '@/api/product/plan/index';
import ProdFile from '@/components/Product/prodFile';
export default {
  name: 'user',
  components: {
    BasicForm,
    UploadList,
    ProdFile
    // 'depart-selector': () =>
    //   import ('./components/departSelector')
  },
  data() {
    return {
      loading: true,
      exportLoading: false,
      pageType: null,
      /* 基本信息 */
      pdsFileModelBaseDto: {
        projectStatus: null,
        projectLevelDv: '',
        salesUserName: '',
        productName: '',
        pdsConfCategory: [],
        certsDvs: [],
        customerIds: [],
        pdsPlanningModelPicsList: [],
        salesAreaRemark: '',
        standard: 1
      },
      detail: {
        /* 负责人 */
        pdsPlanningPrincipals: {
          marketingCenterPrincipal: null,
          pmtPrincipal: null,
          rdPm: null,
          rdSupervisor: null
        },
        /* 销售区域/国家 */
        pdsPlanningModelSalesAreasList: [],
        /* 说明书 */
        pdsPlanningManual: {
          manualFormat: '',
          manualLanguageDvs: []
        },
        /* 市场定位 */
        pdsConfMarketList: [],
        /* 包装方式 */
        pdsPlanningPacking: {
          outerBox: 0,
          outerBoxCapacity: null,
          packageStandard: 1,
          packageType: 'exportBox'
        },
        /* 使用者期望 */
        pdsPlanningExpectationList: [],
        /* 目标成本 */
        pdsPlanningCostList: [],
        /* 知识产权 */
        pdsPlanningIpList: [],
        /* 竞品文件 */
        pdsBenchmarkList: [],
        /* 文档附件 */
        eipFileList: []
      },
      principalLabelList: [
        { label: '营销中心（Sales & Marketing Center）', key: 'marketingCenterPrincipal', id: 16, options: [] },
        { label: '产品管理部（PMT contact）', key: 'pmtPrincipal', id: 22, options: [] },
        { label: '研发中心-项目经理（R&D Project Manager）', key: 'rdPm', id: 15, options: [] },
        { label: '研发中心-二级主管 (R&D Supervisor)', key: 'rdSupervisor', id: 21, options: [] }
      ],
      principalValueList: [],
      countryList: [],
      languageList: [],
      marketFormList: [],
      packageData: {
        outerBoxOptions: [
          {
            labelZhCh: '是',
            labelEnUs: 'Y',
            value: 1,
            id: 1
          },
          {
            labelZhCh: '否',
            labelEnUs: 'N',
            value: 0,
            id: 0
          }
        ],
        packageTypesOptions: [
          {
            value: 'exportBox',
            labelZhCh: '单白盒',
            labelEnUs: '单白盒'
          },
          {
            value: 'colorBox',
            labelZhCh: '彩盒',
            labelEnUs: '彩盒'
          },
          {
            value: 'bmcBox',
            labelZhCh: '吹塑盒',
            labelEnUs: '吹塑盒'
          },
          {
            value: 'nylonBag',
            labelZhCh: '尼龙袋',
            labelEnUs: '尼龙袋'
          }
        ],
        packageStandardOptions: [
          {
            value: 1,
            labelZhCh: 'ISTA 1A',
            labelEnUs: 'ISTA 1A'
          },
          {
            value: 2,
            labelZhCh: 'ISTA 2A',
            labelEnUs: 'ISTA 2A'
          },
          {
            value: 3,
            labelZhCh: 'ISTA 3A',
            labelEnUs: 'ISTA 3A'
          }
        ]
      },
      packageTypeList: ['exportBox', 'colorBox', 'bmcBox', 'nylonBag'],
      ipList: [],
      ipVisible: false,
      ipIndex: null,
      activatedNames: [],
      basicForm: [
        {
          label: '项目状态',
          unit: '',
          element: 'select',
          type: '',
          name: 'projectStatus',
          options: [
            {
              value: 0,
              labelEnUs: '意向',
              labelZhCh: '意向'
            },
            {
              value: 1,
              labelEnUs: '立项',
              labelZhCh: '立项'
            }
          ]
        },
        {
          label: '项目等级',
          unit: '',
          element: 'select',
          type: '',
          name: 'projectLevelDv',
          dictCode: 'pro_plan_level'
        },
        {
          label: '销售对接人',
          unit: '',
          element: 'input',
          type: '',
          name: 'salesUserName'
        },
        {
          label: '产品名称',
          unit: '',
          element: 'input',
          type: '',
          name: 'productName'
        },
        {
          label: '产品小类',
          unit: '',
          element: 'input',
          type: '',
          name: 'productCategoryName'
        },
        {
          label: '单位标准',
          unit: '',
          element: 'select',
          type: '',
          name: 'standard',
          options: [
            { labelEnUs: 'EnStandard', labelZhCh: '欧标', value: 1 },
            { labelEnUs: 'UsStandard', labelZhCh: '美标', value: 2 }
          ]
        },
        {
          label: '产品型号',
          unit: '',
          element: 'input',
          name: 'productModel',
          type: ''
        },
        {
          label: '预计销量',
          unit: '',
          element: 'input',
          name: 'estimatedSales',
          type: 'number'
        },
        {
          label: '业务模式',
          unit: '',
          element: 'select',
          type: '',
          dictCode: 'prod_file_biz_model',
          name: 'productBizModelDv'
        },
        // {
        //   label: '机型码',
        //   unit: '',
        //   element: 'input',
        //   type: '',
        // },
        {
          label: ' 销售年限',
          unit: '',
          element: 'input',
          append: '年',
          name: 'salesPeriod',
          type: 'number'
        },
        {
          label: '客户代码',
          unit: '',
          element: 'input',
          name: 'customerNames',
          value: 'code',
          labelName: 'name'
        },
        {
          label: '市场定位',
          unit: '',
          name: 'marketPositionDv',
          element: 'select',
          dictCode: 'prod_file_market_pos',
          type: ''
        },
        {
          label: '售后保障年限',
          element: 'input',
          append: '年',
          type: 'number',
          name: 'afterSalesPeriod'
        },
        {
          label: '使用寿命',
          unit: '',
          element: 'input',
          append: '小时',
          type: 'number',
          name: 'life'
        },
        {
          label: '证书种类',
          unit: '',
          element: 'select',
          name: 'certsDvs',
          type: 'multiple'
        },
        {
          label: '项目标准周期',
          unit: '',
          element: 'input',
          append: '月',
          type: 'number',
          name: 'projectStandardPeriod'
        },
        {
          label: '计划周期',
          unit: '',
          element: 'input',
          append: '月',
          type: 'number',
          name: 'projectPlanningPeriod'
        },
        {
          label: '要求结案时间',
          unit: '',
          element: 'datePicker',
          type: 'date',
          name: 'projectEndDate'
        },
        {
          label: '品牌',
          unit: '',
          element: 'input',
          type: '',
          name: 'productBrandDv'
        },
        {
          label: '上市年份',
          unit: '',
          element: 'datePicker',
          type: 'year',
          name: 'salesYear'
        },
        {
          label: '产品结构设计',
          unit: '',
          element: 'textarea',
          type: '',
          name: 'productStructureDesign'
        },
        {
          label: '产品造型设计',
          unit: '',
          element: 'textarea',
          type: '',
          name: 'productModelingDesign'
        },
        {
          label: '备注',
          unit: '',
          element: 'textarea',
          type: '',
          name: 'remark'
        },
        {
          label: '参考图片',
          unit: '',
          element: 'upload',
          type: '',
          name: 'pdsPlanningModelPicsList'
        }
      ]
    };
  },
  computed: {
    ...mapGetters(['elements', 'language'])
  },
  activated() {
    this.pageType = this.$route.query.type;
    if (this.pageType === 'export') {
      this.exportLoading = true;
    }
    this.init();
  },
  methods: {
    init() {
      this.planId = this.$route.query.planId;
      this.getDefaultSetting();
      this.getDetail();
    },
    setPdfPage() {
      // let arr_dom = [];
      // page = 1;
      const pdf = document.getElementById('pdf-doc');
      const pageHeight = pdf.offsetWidth / 592.28 * 841.89;

      const preOrder = node => {
        let childs = node.children,
          item;
        for (let i = 0; i < childs.length; i++) {
          item = childs[i];
          if (item.nodeType === 1) {
            // 递归先序遍历子节点
            const offsetTop =
              item.getBoundingClientRect().top -
              pdf.getBoundingClientRect().top;
            const height = item.getBoundingClientRect().height + offsetTop;
            if (Math.floor(offsetTop / pageHeight) != Math.floor(height / pageHeight)) {
              if (item.className.indexOf('el-collapse-item__header') !== -1 || item.children.length == 0) {
                const paddingTop = Math.ceil(offsetTop / pageHeight) * pageHeight - offsetTop + 10;
                console.log('item', item, paddingTop);
                item.setAttribute('style', 'padding-top: ' + paddingTop + 'px');
              }
              preOrder(item);
            }
          }
        }
      };
      preOrder(pdf);
    },
    /* 单选值查询 */
    getValue(list, keyName, valueName, value) {
      for (let i = 0; i < list.length; i++) {
        if (list[i][keyName] == value) {
          return list[i][valueName];
        }
      }
    },
    /* 多选值查询 */
    getValues(listName, keyName, valueName, valueList) {
      const list = this[listName];
      const resList = [];
      list.map(item => {
        valueList.map(subItem => {
          if (item[keyName] == subItem) {
            resList.push(item[valueName]);
          }
        })
      })
      return resList.join(',');
    },
    getDefaultSetting() {
      this.getPdsConfCategoryTree();
      this.getTypeValue('prod_file_biz_model', 8);
      this.getTypeValue('prod_file_market_pos', 11);
      this.getTypeValue('pro_plan_level', 1);
      this.getCertSelect();
      this.getSalesCountry();
      this.getLanguageList();
      this.getPrincipalValue();
      this.getMarket();
      this.getExpectation();
      this.getCost();
      this.getIpList();
      this.getCustomerList();
    },
    categoryChanged(val) {
      if (val.length === 3) {
        this.$refs.prodfile.prodCategoryChanged(val[2]);
      }
    },
    getDetail() {
      planApi.getDetail({ id: this.planId }).then(res => {
        this.getSubDetail();
        if (res.code == 200) {
          this.setPdfPage();
          this.exportLoading = false;
          /* 销售对接人 */
          this.$set(this, 'pdsFileModelBaseDto', res.data);
          if (res.data.salesUser) {
            baseApi.getUserByIds(res.data.salesUser).then(saleUserData => {
              if (saleUserData.code == 200) {
                this.$set(this.pdsFileModelBaseDto, 'salesUserName', saleUserData.data[0].name);
              }
            })
          }
          const setMulSelect = str => {
            let arr = str.split(',');
            arr = arr.map(row => Number(row));
            return arr;
          };
          this.$set(
            this.pdsFileModelBaseDto,
            'pdsConfCategory',
            setMulSelect(res.data.productCategoryIds)
          );
          this.$set(
            this.pdsFileModelBaseDto,
            'certsDvs',
            setMulSelect(res.data.certsDvs)
          );
          console.log('detail', this.pdsFileModelBaseDto);
          this.loading = false;
        }
      });
    },
    getSubDetail() {
      planApi.getSubDetail({ id: this.planId }).then(res => {
        if (res.code == 200) {
          /* 销售国家 */
          res.data.pdsPlanningModelSalesAreasList = res.data.pdsPlanningModelSalesAreasList.map(item => item.salesAreaDv);
          /* 说明书语言 */
          res.data.pdsPlanningManual.manualLanguageDvs = res.data.pdsPlanningManual.manualLanguageDvs.split(',');
          /* 市场定位 */
          const marketList = JSON.parse(JSON.stringify(res.data.pdsConfMarketList));
          res.data.pdsConfMarketList = [];
          marketList.map(item => {
            if (item.isChecked) {
              res.data.pdsConfMarketList.push(item);
            }
          })
          /* 包装方式 */
          this.packageTypeList.map(item => {
            if (res.data.pdsPlanningPacking[item]) {
              res.data.pdsPlanningPacking.packageType = item;
            }
          })
          this.packageData.packageTypesOptions.map(item => {
            if (res.data.pdsPlanningPacking.packageType == item.value) {
              res.data.pdsPlanningPacking.packageTypeLabel = item.labelZhCh;
            }
          })
          /* 知识产权 */
          this.ipList = JSON.parse(JSON.stringify(res.data.pdsPlanningIpList));
          res.data.pdsPlanningIpList = [];
          this.ipList.map((item, index) => {
            if (item.ipAscription || item.ipProtection) {
              res.data.pdsPlanningIpList.push({
                ...item,
                listIndex: index
              })
              item.disabled = true;
            }
          })
          /* 产品档案 */
          res.data.pdsModuleItemsAndValueVOList.map((item, index) => {
            this.activatedNames.push(index);
          });
          // this.detail = Object.assign(this.detail, res.data);
          this.detail = res.data;
          console.log('this.detail', this.detail);
        }
      });
    },
    getPdsConfCategoryTree() {
      prodApi.getPdsConfCategoryTree().then(res => {
        this.basicForm[4].options = res.data;
      });
    },
    getTypeValue(code, index) {
      baseApi.getTypeValue(code).then(res => {
        this.$set(this.basicForm[index], 'options', res.data.rows);
      });
    },
    getCertSelect() {
      prodApi.certSelect().then(res => {
        this.basicForm[14].options = res.data;
      });
    },
    getSalesCountry() {
      const codes = 'prod_file_sales_area';
      baseApi.getTypesValue(codes).then(res => {
        this.countryList = res.data[codes];
        this.countryList.map(row => {
          row.salesAreaDv = row.value;
          return row;
        });
        this.$set(this, 'countryList', res.data[codes]);
      });
    },
    getLanguageList() {
      const codes = 'pro_plan_manual';
      baseApi.getTypesValue(codes).then(res => {
        this.languageList = res.data[codes];
        this.$set(this, 'languageList', res.data[codes]);
      });
    },
    /* 客户信息列表 */
    getCustomerList() {
      baseApi.getCustomerList().then(res => {
        this.basicForm[10].options = res.data;
      });
    },
    /* 负责人选项列表 */
    // getPrincipalValue() {
    //   baseApi.getBaseUser().then(res => {
    //     this.principalValueList = res.data;
    //   });
    // },
    async getPrincipalValue() {
      for (let i = 0; i < this.principalLabelList.length; i++) {
        const res = await baseApi.getDepartAdmin({ departId: this.principalLabelList[i].id });
        this.principalLabelList[i].options = res.data.rows;
      }
    },
    /* 市场定位选项列表 */
    getMarket() {
      baseApi.getMarket().then(res => {
        this.detail.pdsConfMarketList = res.data;
        this.detail.pdsConfMarketList.map(item => {
          item.configId = item.id;
          item.isChecked = false;
        })
      });
    },
    /* 使用者期望 */
    getExpectation() {
      baseApi.getExpectation().then(res => {
        const list = [];
        for (let i = 0; i < res.data.length; i++) {
          list.push({
            configId: res.data[i].id,
            // expectationConfigId: res.data[i].id,
            dataLabel: res.data[i].dataLabel,
            expectationValue: ''
          });
        }
        this.detail.pdsPlanningExpectationList = list;
      });
    },
    /* 目标成本 */
    getCost() {
      baseApi.getCost().then(res => {
        const list = [];
        for (let i = 0; i < res.data.length; i++) {
          list.push({
            // costConfigId: res.data[i].id,
            configId: res.data[i].id,
            dataLabel: res.data[i].dataLabel,
            bearer: '',
            costValue: ''
          });
        }
        this.detail.pdsPlanningCostList = list;
      });
    },
    /* 知识产权 */
    getIpList() {
      baseApi.getIpList().then(res => {
        this.ipList = res.data;
      });
    },
    /* 添加知识产权 */
    chooseIp() {
      this.detail.pdsPlanningIpList.push({
        ipAscription: '',
        // ipConfigId: this.ipList[this.ipIndex].id,
        configId: this.ipList[this.ipIndex].id || this.ipList[this.ipIndex].configId,
        dataLabel: this.ipList[this.ipIndex].dataLabel,
        ipProtection: '',
        listIndex: this.ipIndex
      });
      this.ipList[this.ipIndex].disabled = true;
      this.ipVisible = false;
      this.ipIndex = null;
    },
    /* 删除知识产权 */
    delIp(index) {
      this.ipList[
        this.detail.pdsPlanningIpList[index].listIndex
      ].disabled = false;
      this.detail.pdsPlanningIpList.splice(index, 1);
    }
  }
};
</script>
